﻿using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Genrsis.WorkitemTracking.Handlers;

namespace Genrsis.WorkitemTracking.Web.Infrastructure.IoC
{
    public class CommandInstaller : IWindsorInstaller
    {
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            container.Register(
                AllTypes.FromAssemblyContaining(typeof(ICommandHandler<>))
                    .BasedOn(typeof(ICommandHandler<>))
                    .WithService.DefaultInterface(),

                Component.For<ICommandHandlerFactory>()
                    .AsFactory(),

                Component.For<ICommandProcessor>()
                    .ImplementedBy<CommandProcessor>()
                );
        }
    }
}